home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / libraries / curses210.lha / src / tparm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  2.6 KB  |  101 lines

  1. /* -*-C-*-
  2.  *
  3.  * Filename : SRC:lib/curses/src/tparm.c
  4.  *
  5.  * Author   : Simon J Raybould.    (sie@fulcrum.co.uk).
  6.  *
  7.  * Date     : Mon Aug 16 21:40:58 1993
  8.  *
  9.  * Desc     : tparm() call, obvious really.
  10.  *
  11.  *
  12.  * THIS CODE IS NOT PUBLIC DOMAIN
  13.  * ==============================
  14.  * 
  15.  * This code is copyright Simon J Raybould 1993, all rights are reserved.
  16.  * All code, ideas, data structures and algorithms remain the property of the
  17.  * author. Neither the whole nor sections of this code may be used as part
  18.  * of other code without the authors consent. If you wish to use some of this
  19.  * code then please email me at (sie@fulcrum.bt.co.uk).
  20.  *
  21.  * This source is not public domain, so you do not have any right to alter it
  22.  * or sell it for personal gain. The source is provided purely for reference
  23.  * purposes. You may re-compile the source with any compiler you choose.
  24.  * You must not distribute altered copies without the authors consent. My
  25.  * intention is that the source will help people isolate any bugs much more
  26.  * effectively.
  27.  *
  28.  * Disclaimer
  29.  * ==========
  30.  *
  31.  * No implication is made as to this code being fit for any purpose at all.
  32.  * I (the author) shall not be held responsible for any loss of data or damage 
  33.  * to property that may result from its use or misuse.
  34.  *
  35.  *
  36.  * Revision History
  37.  * ================
  38.  *
  39.  * $Log: tparm.c,v $
  40.  * Revision 1.1  1994/02/21  22:18:41  sie
  41.  * Initial revision
  42.  *
  43.  *
  44.  *
  45.  */
  46.  
  47. #ifndef TARGET
  48. #ifndef lint
  49. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/tparm.c,v 1.1 1994/02/21 22:18:41 sie Exp $";
  50. #endif /* lint */
  51. #endif /* TARGET */
  52.  
  53.  
  54.  
  55.  
  56.  
  57. char *
  58. tparm(char *str, ...)
  59. {
  60.   static char buf[80];
  61.   char *ptr = str, *bptr = buf;
  62.   
  63.   while(*ptr) {
  64.     if(*ptr == '%') {
  65.       if(!*++ptr)
  66.         break;
  67.       switch(*ptr) {
  68.       case 'd':                 /* decimal value */
  69.         bptr += sprintf(bptr, "%d", line);
  70.         swap(&line, &col);
  71.         break;
  72.       case '2':                 /* decimal value */
  73.         bptr += sprintf(bptr, "%2d", line);
  74.         swap(&line, &col);
  75.         break;
  76.       case '3':                 /* decimal value */
  77.         bptr += sprintf(bptr, "%3d", line);
  78.         swap(&line, &col);
  79.         break;
  80.       case '.':                 /* character value */
  81.         bptr += sprintf(bptr, "%c", line);
  82.         swap(&line, &col);
  83.         break;
  84.       case 'r':                 /* reverse line and col */
  85.         swap(&line, &col);
  86.         break;
  87.       case 'i':                 /* in line and col */
  88.         line++;
  89.         col++;
  90.         break;
  91.       case '%':
  92.         *bptr++ = '%';
  93.         break;
  94.       }
  95.     } else
  96.       *bptr++ = *ptr;
  97.     ptr++;
  98.   } /* end of while(*ptr) */
  99.   return buf;
  100. }
  101.